﻿using Se.Model.GameModel.Card;
using Se.Model.GameModel.Character;
using Se.Model.Host;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SeServer.Module.Table
{
    public class TableController : ModuleControllerBase
    {

        const ControllerType M_TYPE = ControllerType.Account;
        public TableController()
            : base(M_TYPE)
        {
            this.TableCollection = new Dictionary<long, CardTable>();
            this.CardPlayerCollection = new Dictionary<long, CardPlayer>();
        }

        /// <summary>
        /// Table集合，Key：tableid
        /// </summary>
        public Dictionary<long, CardTable> TableCollection;

        /// <summary>
        /// CardPlayer集合，Key：playerid
        /// </summary>
        public Dictionary<long, CardPlayer> CardPlayerCollection;

        #region interface ModuleControllerBase

        public override void InitModule()
        {

        }

        public override void LoadTemplates()
        {

        }

        public override void LoadMemoryData()
        {

        }

        public override void LoadPlayerData(Player player)
        {

        }

        #endregion


        /// <summary>
        /// 进入牌桌
        /// </summary>
        /// <param name="session"></param>
        /// <param name="tableId"></param>
        /// <param name="playerId"></param>
        public void EnterTable(SocketSession session, long tableId)
        {
            if (session == null || session.Player == null) return;

            if (!this.TableCollection.ContainsKey(tableId)) return;
            var table = this.TableCollection[tableId];
            var result = table.TryEnter(session.Player);
            if (result.IsSuccess)
            {
                //TODO 进入成功
            }
            else
            {
                //TODO 进入失败
            }
        }
    }
}
